\name{newMap}
\Rdversion{1.1}
\alias{newMap}

\title{
Sets an existing device up for plotting maps
}
\description{
Sets an existing device up for plotting maps
}
\usage{
newMap(mapToPlot, oceanColour, projection, mapRegion, aspect)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{mapToPlot}{
%%     ~~Describe \code{mapToPlot} here~~
}
  \item{oceanColour}{
%%     ~~Describe \code{oceanColour} here~~
}
  \item{projection}{
%%     ~~Describe \code{projection} here~~
}
  \item{mapRegion}{
%%     ~~Describe \code{mapRegion} here~~
}
  \item{aspect}{
%%     ~~Describe \code{aspect} here~~
}
}
\details{
%%  ~~ If necessary, more details than the description above ~~
}
\value{
%%  ~Describe the value returned
%%  If it is a LIST, use
%%  \item{comp1 }{Description of 'comp1'}
%%  \item{comp2 }{Description of 'comp2'}
%% ...
}
\references{
%% ~put references to the literature/web site here ~
}
\author{
%%  ~~who you are~~
}
\note{
%%  ~~further notes~~
}



\seealso{
%% ~~objects to See Also as \code{\link{help}}, ~~~
}
\examples{
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(mapToPlot,oceanColour,projection,mapRegion,aspect){
if (mapRegion != "world"){
    dFwesn <- setMapExtents(mapRegion)
    xlim=c(dFwesn$we,ea=dFwesn$ea)
    ylim=c(so=dFwesn$so,no=dFwesn$no)
  }else{
    xlim=bbox(mapToPlot)[1,]
    ylim=bbox(mapToPlot)[2,]
  }
  ## 10/9/08 trying to use estimated coord conversion rather than proper projection through spTransform
  ## ! this may be risky if users want to put points on map
  ## ! but should be OK if just for coloured countries
  if (projection=="EqualArea" || projection=="equalArea"){
    xlim=xlim*100000
    ylim=ylim*100000
  }
  plot.new()

  #replicate behaviour of plot.Spatial in the sp package regarding aspect.
  if (is.na(aspect))
        aspect <- ifelse(is.na(proj4string(mapToPlot)) || is.projected(mapToPlot),
            1, 1/cos((mean(ylim) * pi)/180))

  plot.window(xlim=xlim,ylim=ylim,asp=aspect)
  rect(xlim[1],ylim[1],xlim[2],ylim[2],col=oceanColour,border=oceanColour)
  }
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{misc}

